﻿<!--
 Copyright 2013 Shawn Henry, Rob Smith, and Michael Friedman

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<view:AViewPage
    x:Class="OneBusAway.WP7.View.SettingsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:data="clr-namespace:OneBusAway.WP7.ViewModel;assembly=OneBusAway.WP7.ViewModel" 
    xmlns:view="clr-namespace:OneBusAway.WP7.View;assembly=OneBusAway.WP7.View"
    xmlns:local="clr-namespace:OneBusAway.WP7.View"
    xmlns:tilt="clr-namespace:ControlTiltEffect"
    xmlns:toolbox="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    tilt:TiltEffect.IsTiltEnabled="True"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource OBAForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <view:AViewPage.Resources>
        <data:SettingsVM x:Key="ViewModel" />
        <view:PivotNameConverter x:Key="PivotNameConverter" />
    </view:AViewPage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource OBAPrimaryBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="11" />
            <ColumnDefinition Width="469" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Margin="1,16,0,27" Grid.Column="1">
            <TextBlock x:Name="PageTitle" Text="settings" 
                Foreground="{StaticResource OBAForegroundBrush}"
                Margin="9,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <ScrollViewer x:Name="ContentPanel" Grid.Row="1" Margin="1,0,12,0" Grid.Column="1">
            <StackPanel>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <toolbox:ToggleSwitch
                    x:Name="ReportUsageTs"
                    Grid.Row="0"
                    IsChecked="{Binding Path=FeedbackEnabled, Source={StaticResource ViewModel}, Mode=TwoWay}"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    Header="Send feedback"
                    />

                    <TextBlock 
                    Grid.Row="1"
                    Margin="10,-20,0,0"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    FontSize="{StaticResource PhoneFontSizeSmall}"
                    Text="Sending anonymous usage data allows us to better improve the OneBusAway app.  We will never report your location or any personally-identifying information. You must restart OneBusAway for any changes to this setting to take effect."
                    TextWrapping="Wrap"
                    />
                </Grid>

                <toolbox:ListPicker 
                x:Name="DefaultPivotLp"
                ItemsSource="{Binding Path=MainPagePivotOptions, Source={StaticResource ViewModel}, Converter={StaticResource PivotNameConverter}}"
                SelectedItem="{Binding Path=SelectedMainPagePivot, Source={StaticResource ViewModel}, Converter={StaticResource PivotNameConverter}, Mode=TwoWay}"
                Header="Default pivot when starting OneBusAway"
                />

                <TextBlock
                Text="Clear recents and cache"
                Foreground="{StaticResource OBAForegroundBrush}"
                Margin="10,0,0,0"
                />
                <Button Content="delete local cache" Name="clear_history_button"  Click="appbar_clear_history_Click"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    BorderBrush="{StaticResource OBAForegroundBrush}"
                    HorizontalAlignment="Stretch" VerticalAlignment="Top"
                    />

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <toolbox:ToggleSwitch
                    x:Name="ThemeToggle"
                    Grid.Row="0"
                    IsChecked="{Binding Path=UseNativeTheme, Source={StaticResource ViewModel}, Mode=TwoWay}"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    Header="Use system theme"
                    />

                    <TextBlock 
                    Grid.Row="1"
                    Margin="10,-20,0,0"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    FontSize="{StaticResource PhoneFontSizeSmall}"
                    Text="Apply your phone's system theme to the application.  You must restart OneBusAway for any changes to this setting to take effect."
                    TextWrapping="Wrap"
                    />
                </Grid>

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <toolbox:ToggleSwitch
                    x:Name="UseLocationTs"
                    Grid.Row="0"
                    IsChecked="{Binding Path=UseLocation, Source={StaticResource ViewModel}, Mode=TwoWay}"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    Header="Use location"
                    />

                    <TextBlock 
                    Grid.Row="1"
                    Margin="10,-20,0,0"
                    Foreground="{StaticResource OBAForegroundBrush}"
                    FontSize="{StaticResource PhoneFontSizeSmall}"
                    Text="The WP7 OneBusAway app never saves your location information, and only uses the information to find nearby buses and routes using the services provided by OneBusAway.org. For more information please view OneBusAway.org's complete privacy policy: http://onebusaway.org/p/PrivacyPolicy.action"
                    TextWrapping="Wrap"
                    />
                </Grid>
            </StackPanel>
        </ScrollViewer>
    </Grid>

</view:AViewPage>
